<template>
  <div class="data-title">
    <h3>{{ text }}</h3>
    <div class="data-tabs" v-show="hasTab">
      <div
        class="data-tabs-list"
        :class="{ selected: isActive == index }"
        v-for="(item, index) in tabs"
        :key="index"
        @click="selectTablist(index)"
      >
        {{ item.title }}
      </div>
      <el-date-picker
      class="date-picker"
        v-if="isActive == 3"
        v-model="time"
        type="daterange"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      >
      </el-date-picker>
    </div>
  </div>
</template>

<script>
export default {
  name: "title",
  props: {
    text: {
      type: String,
      default() {
        return "接入情况";
      },
    },
    hasTab: {
      type: Boolean,
      default() {
        return true;
      },
    },
  },
  data() {
    return {
      isActive: 0,
      tabs: [
        {
          title: "近一日",
        },
        {
          title: "近一周",
        },
        {
          title: "近一月",
        },
        {
          title: "自定义",
        },
      ],
      time: "",
    };
  },
  methods: {
    selectTablist(index) {
      this.isActive = index;
      this.$emit("selectTablist", index);
    },
  },
};
</script>

<style lang="scss" scoped>
.el-date-editor--daterange.el-input__inner {
  width: 260px !important;
}

.data-title {
  height: 60px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  h3 {
    font-size: 18px;
    margin: 0;
    flex: 1;
  }

  .data-tabs {
    display: flex;
    align-items: center;
    .data-tabs-list {
      width: 110px;
      height: 32px;
      text-align: center;
      line-height: 32px;
      font-size: 14px;
      margin: 0 5px;
      cursor: pointer;
      border-radius: 4px;
      border: 1px solid rgba(0, 0, 0, 0.15);
    //  margin-top: 20px;
     margin-bottom: 12px;    
     background-color: #FFFFFF ;     
     color: rgba(0,0,0,0.85);      
     
    }
    .date-picker{
      margin-top: -8px;
    }
  }
}

.selected {
  color: #ffffff !important;
  background: #4b6eef !important;
  border: 1px solid rgba(75, 110, 239, 1) !important;
}
</style>
